<?php
	$currentItem = "BulletinAdmin";
	$currentSubItem = "updateBulletin";
?>
<include file="./Tpl/default/Admin/Public/header.html" />

<!--kindeditor-->
<script charset="utf-8" src="../Public/editor/kindeditor.js">
</script>

<script>
	KE.show({
	    id : 'message'
	});

</script>

<!--添加文件上传的input-->
<script language="JavaScript">
	function addFileInput(){
		var newInput = document.createElement("input");
		newInput.type='file'; 
		newInput.name="affixFiles[]"; 
		
		var isFileInput = document.createElement("input");
		isFileInput.type='hidden'; 
		isFileInput.name="isFile";
		isFileInput.value="true";
				
		var fileDiv =document.getElementById("fileDiv")
		fileDiv.appendChild(newInput); 
		fileDiv.appendChild(isFileInput); 
	}


	//用于添加公告的子类型select	
	$(document).ready(function(){
		
		$('#type').change(
			function(){
				if($('#type option:selected').val() == 2){
					var seletedIndex = $('#subtypeValue').val();
					var htmlString = '<select name="subtype" id="subtype">' + 
									 '<option value="0">课程表</option>' + 
									 '<option value="1">教务通知</option>' +
									 '<option value="2">学籍管理</option>' +
									 '</select>';
									 
					 $('#subtypeDiv').append(htmlString);
					 if(seletedIndex != null){
						 
					 	$('#subtype').get(0).selectedIndex = seletedIndex;
					 }
					 
				}else{
					$('#subtype').remove();
			
				}
				
			});		
	});
</script>

<div>
	<h2>修改公告页面</h2>
	
	<br>
	
	
	
	<form id="BulletinForm" method="post" action="__APP__/Admin/BulletinAdmin/updateCommit" enctype="multipart/form-data">

		<ul>

			<li>
				<label>选择发布的公告类型</label>
				<select name="type" id="type">
					<option value="0" <?php if($bulletin['type'] == 0) echo 'selected'?> >学院通知</option>
					<option value="1" <?php if($bulletin['type'] == 1) echo 'selected'?>>研究生事务</option>
					<option value="2" <?php if($bulletin['type'] == 2) echo 'selected'?>>本科生事务</option>
					<option value="3" <?php if($bulletin['type'] == 3) echo 'selected'?>>科研通知</option>			
				</select>	
			
			</li>
			
			
			
			<li>
				<div id="subtypeDiv">
				<?php 
					if($bulletin['subtype'] != null){
				?>
					<select name="subtype" id="subtype">
						<option value="0" <?php if($bulletin['subtype'] == 0) echo 'selected'?> >课程表</option>
						<option value="1" <?php if($bulletin['subtype'] == 1) echo 'selected'?>>教务通知</option>
						<option value="2" <?php if($bulletin['subtype'] == 2) echo 'selected'?>>学籍管理</option>
					</select>
				<?php 
					}
				?>
				</div>
				<input type="hidden" value="<?php echo $bulletin['subtype'];?>" id="subtypeValue">
			</li>
			
			
			<li>
				<label>标题：</label>
				<input type="text" name="title" value="<?php echo $bulletin['title']?>">
			</li>
			
			<li>
				<label>副标题：</label>
				<input type="text" name="subtitle" value="<?php echo $bulletin['subtitle']?>">
			</li>
			
			<!--	输出公告的附件		-->
			<?php 
				if($bulletinAffixList != null){
					foreach ($bulletinAffixList as $vo){
			?>
				{$vo['filename']}
				<a href="__APP__/Admin/BulletinAdmin/deleteAffix/bulletin_id/{$bulletin['bulletin_id']}/affix_id/{$vo['affix_id']}">删除</a>
				<br>
			<?php
						}
				}
			?>
			<!--	End 输出公告的附件		-->
			
			<li>
				<div id="fileDiv">
					<input type="button" onclick="addFileInput()" value="添加附件">
				</div>
			</li>
			
			
			<li>
				
				<textarea id="message"
						  name="message"
						  style="width:700px;height:300px;"
						  >
			 		   <?php
			 		   		echo $bulletin['message'];
			 		   ?>
			 		     
			 	</textarea>			
			</li>

			<li>
				<input type="hidden" value="<?php echo $bulletin['bulletin_id']?>" name="bulletin_id">
				<input  type="submit" value="提交更新">
				<strong><a href="__APP__/Admin/BulletinAdmin">返回</a></strong>
				
			</li>
			
		</ul>

	</form>

</div>

<include file="./Tpl/default/Admin/Public/footer.html" />
